package com.biunova.novapay.service.impl;

import com.biunova.novapay.dao.OrderDao;
import com.biunova.novapay.entity.Order;
import com.biunova.novapay.service.OrderService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class OrderServiceImpl implements OrderService {

    private final OrderDao orderDao;

    public OrderServiceImpl(OrderDao orderDao) {
        this.orderDao = orderDao;
    }

    @Override
    public void createOrder(Order order) {
        orderDao.insertOrder(order);
    }

    @Override
    public void modifyOrder(Order order) {
        orderDao.updateOrder(order);
    }

    @Override
    public void removeOrder(Long orderId) {
        orderDao.deleteOrder(orderId);
    }

    @Override
    public Order fetchOrderById(Long orderId) {
        return orderDao.getOrderById(orderId);
    }

    @Override
    public List<Order> fetchAllOrders() {
        return orderDao.getAllOrders();
    }

    @Override
    public Order fetchOrderByOrderNumber(String outTradeNo) {
        return orderDao.findByOrderNumber(outTradeNo);
    }
}
